package com.prs.crm.action.sys;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;

import com.prs.crm.domain.sys.AppDefaultTitle;
import com.prs.crm.domain.sys.DeskBottomSet;
import com.prs.crm.domain.sys.InfoDefaultTitle;
import com.prs.crm.service.sys.AppDefaultTitleService;
import com.prs.crm.service.sys.DeskBottomSetService;
import com.prs.crm.service.sys.InfoDefaultTitleService;

public class DeskBottomSetAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private DeskBottomSet deskBottomSet;
	private DeskBottomSetService deskBottomSetService;
	private String serCode;
	
	public String getSerCode() {
		return serCode;
	}
	public void setSerCode(String serCode) {
		this.serCode = serCode;
	}

	public DeskBottomSet getDeskBottomSet() {
		return deskBottomSet;
	}
	public void setDeskBottomSet(DeskBottomSet deskBottomSet) {
		this.deskBottomSet = deskBottomSet;
	}
	public DeskBottomSetService getDeskBottomSetService() {
		return deskBottomSetService;
	}
	public void setDeskBottomSetService(DeskBottomSetService deskBottomSetService) {
		this.deskBottomSetService = deskBottomSetService;
	}
	@Action("editDeskBottomSet")
	public String editDeskBottomSet(){
		this.deskBottomSet=this.getDeskBottomSetService().getDeskBottomSet(serCode);
		return SUCCESS;
	}
	@Action(value="saveDeskBottomSet",results={
			@Result(name="success",type="redirect",location="editDeskBottomSet?serCode=${deskBottomSet.getType()}"),
			@Result(name="error",type="chain",location="editDeskBottomSet?serCode=$(deskBottomSet.getType()}")
	})
	public String saveDeskBottomSet(){
		DeskBottomSet ds=this.getDeskBottomSetService().getDeskBottomSet("ds01");
		if(ds==null){
			ds=new DeskBottomSet();
			ds.setType("ds01");
			ds.setRemark(deskBottomSet.getRemark());
			ds.setContent(deskBottomSet.getContent());
			ds.setIsSelect(deskBottomSet.getIsSelect());
			ds.setShowInform(deskBottomSet.getShowInform());
			ds.setShowNews(deskBottomSet.getShowNews());
			ds.setShowNotice(deskBottomSet.getShowNotice());
			ds.setNum1(deskBottomSet.getNum1());
			ds.setNum2(deskBottomSet.getNum2());
			ds.setNum3(deskBottomSet.getNum3());
			ds.setShows(deskBottomSet.getShows());
			this.getDeskBottomSetService().save(ds);
		}else{
			this.getDeskBottomSetService().submit(ds);
		}
			deskBottomSet=ds;
		return SUCCESS;
	}
}
